<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/login.css">
</head>
<body>
    <div class="banner-l">
        <img src="../images/banner.4994397e.jpg" alt="">
    </div>
    <div class="banner-r">
        <h1>欢迎来到登录界面</h1>
        <div class="banner-r-c">
            <input name="userName" type="text" placeholder="请输入用户名">
            <input name="userPwd" type="password" placeholder="请输入密码">
            <button class="login">登录</button> <br>
            <a href="">忘记密码？</a>
            <a href="">手机号登录</a>
            <p name="comment"></p>
        </div>
    </div>

    <script src="../tools/jquery.min.js"></script>
    <script src="../js/myAjax.js"></script>
    <script src="../js/cookie.js"></script>
    <script>
        $('button').click(function(){
            const xhr = myPromiseJQueryAjax('../server/goods_login.php','post',{userName:$('[name="userName"]').val(),userPwd:$('[name="userPwd"]').val()},'json');
            xhr.then(function(res){
                console.log(res);
                if(res.result === 1){
                    mySetCookie('login',1,7*24*60*60,'/');
                    let time = 5;
                    $('[name="comment"]').html('恭喜您注册成功，将在5秒后跳转').css('color','red');

                    setInterval(() => {
                        time --;
                        if(time === 0){
                            window.location.href = `${window.location.search.substr(5)}`;
                            return;
                        }
                    $('[name="comment"]').html(`恭喜您注册成功，将在${time}秒后跳转`).css('color','red');
                    }, 1000);
                }
            })
        })
    </script>
</body>
</html>